<!DOCTYPE html>
<html>
    <head>
        <script src="js/vue.js"></script>
        <script src="js/vuex.js"></script>
    </head>
    <body>
        <div id="app">
            <button @click="paramM" >传递参数</button>
            <p>{{this.$store.state.param}}</p>
        </div>
        <script>
            const store = new Vuex.Store({
                state : {
                    param : 0
                },
                mutations : {
                    receive(state,param1){
                        state.param = param1
                    }
                },
                actions : {
                    param(context,param2){
                        context.commit('receive',param2)
                    }
                }
            })

            var vm = new Vue({
                el:'#app',
                store,
                methods : {
                    paramM() {
                        this.$store.dispatch('param',' 我是要传递的参数2')
                    }
                }
            })
        </script>
    </body>
</html>